<?php
function theme_widget_cfg_qf_category(){
   	$cat_mdl = app::get('b2c')->model('goods_cat');//商品分类接口 
    $cat_list =$cat_mdl->get_cat_list();//取出所有分类-无序
    $all_cids = array();
    foreach ($cat_list as $k=>$cat) {
        switch ($cat['step']) {
        case 1:
            $all_cids 	= _ex_getAllChildAttr($cat_list,$cat['cat_id']);
            $all_cids[] 	= $cat['cat_id'];
            $all_typeids 	= _ex_getAllChildAttr($cat_list,$cat['cat_id'],'type');
            $all_typeids[] 	= $cat['type'];	
            $_returnData['cats'][$cat['cat_id']] = $cat;
            break;
        case 2:
            $_returnData['cats'][$cat['pid']]['lv2'][$cat['cat_id']] = $cat;
            break;
        }//end switch
    }
	//print_r($_returnData);exit;
	return $_returnData;
}

//获得商品分类
function _ex_getAllChildAttr($arr,$pid,$attribute = 'cat_id'){
    foreach ($arr as $item) {
        if(in_array($pid, explode(',', $item['cat_path']))){
            $_return[] = $item[$attribute];
        }
    }
    return $_return;
}
?>